﻿using AutoMapper;
using BCVP.Net8.IService;
using BCVP.Net8.Model.ViewModel;
using BCVP.Net8.Repository.Base;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BCVP.Net8.Service
{
    public class BaseService<TEntity, TMV> : IBaseService<TEntity, TMV> where TEntity : class,new()
    {
        private readonly IMapper _mapper;
        private readonly IBaseRepository<TEntity> _baseRepository;

        public BaseService(IMapper mapper,IBaseRepository<TEntity> baseRepository) 
        {
            this._mapper = mapper;
            this._baseRepository = baseRepository;
        }
        public async Task<List<TMV>> Query()
        {
            return _mapper.Map<List<TMV>>(await _baseRepository.Query());
        }
    }
}
